/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef DEVICES_RECEIVER_H
#define DEVICES_RECEIVER_H


/* Includes ------------------------------------------------------------------*/
#include "app_typedef.h"
#include "usart.h"



/* Exported constants --------------------------------------------------------*/
#ifdef LIDAR_USE_CODE
#define Lidar_MsgReceiveLength 30
#endif
#ifdef RECEIVE_USE_CODE
#define Lidar_MsgReceiveLength 31
#endif

/* Exported macros -----------------------------------------------------------*/
#define Receiver_FucGroundInit \
{ \
	&Receiver_Reconstruction, \
	&Receiver_Reconstruction_OldProtocol, \
	&Receiver_Add_RecBaterry,\
}


/* Exported types ------------------------------------------------------------*/
/* Using Grand unions */
#pragma anon_unions


/*
 * Lidar Message Receiver
 */
typedef struct
{
	union
	{
		uint8_t Lidar_MsgReceive[Lidar_MsgReceiveLength];
		struct
		{
			uint16_t SOF;
			uint16_t DataLength;
			uint16_t LidarMode;
			uint16_t LidarDataState;
			
			uint16_t Min_LineAngle;
			uint16_t Min_LineDistance;
			
			int16_t Tree_Barrier1_X;
			int16_t Tree_Barrier1_Y;
			int16_t Tree_Barrier2_X;
			int16_t Tree_Barrier2_Y;
			uint16_t Battary_Voltage;
			uint16_t SumCheck;
			
			uint16_t Rec_Voltage;
			uint16_t Reserve2;
			uint16_t Reserve3;
			#ifdef RECEIVE_USE_CODE
			uint8_t rssi;
			#endif
		};
	};
}Lidar_MessageReceiver_t;


typedef struct
{
	void(*Receiver_Reconstruction)(Lidar_MessageReceiver_t* LMR_In,char FakeATCommand[]);
	void(*Receiver_Reconstruction_OldProtocol)(Lidar_MessageReceiver_t* LMR_In,uint8_t* Fake_Old_Command);
	void (*Receiver_Add_RecBaterry)(float recpercent,Lidar_MessageReceiver_t* LMR_In);
}Receiver_Fuc;



/* Exported variables --------------------------------------------------------*/
extern Receiver_Fuc Receiver_Function;
extern Lidar_MessageReceiver_t Receiver_LidarPusherReceive;
extern char Fake_ATCommand[51];
extern uint8_t Fake_OldCommand[23];
/* End -----------------------------------------------------------------------*/
#endif

